package asapIs134CK.womi.client.games.logoGame.utils;

import asapIs134CK.womi.client.games.logoGame.utils.exceptions.ValueException;

public class SimplePositionTraker {
	private Position _current;
	private Position _previous;
	
	public SimplePositionTraker(int x, int y) throws ValueException{
		_current = new Position(x,y);
		_previous = new Position(x, y);	
	}
	public SimplePositionTraker(SimplePositionTraker spTraker){
		_current = new Position(spTraker._current);
		_previous = new Position(spTraker._previous);
	}
	public SimplePositionTraker(Position pos){
		_current = new Position(pos);
		_previous = new Position(pos);
	}
	
	public Position getPosition(){return _current;}
	public int getX(){return _current.getX();}
	public int getY(){return _current.getY();}
	
	public boolean equals(Object arg0){
		boolean isEquals = false;
		if (arg0 instanceof SimplePositionTraker) {
			SimplePositionTraker spTraker = (SimplePositionTraker) arg0;
			isEquals = this._current.equals(spTraker._current);
		}
		return isEquals;
	}
	public void setX(int i) throws ValueException{
		Position tempPos = new Position(_current);
		_current.setX(i);//if no exception then 
		_previous = tempPos;
	}
	public void setY(int i) throws ValueException{
		Position tempPos = new Position(_current);
		_current.setY(i);//if no exception then 
		_previous = tempPos;
	}
	public void setPosition(Position newPosition){
		_previous = _current;
		_current = newPosition;
	}
	public boolean isEquals(int x, int y){
		return _current.isEquals(x, y);
	}
	@Override
	public String toString() {
		return _current.toString();
	}
	public Position getPrevious() {
		return _previous;
	}
	
}
